<?php

namespace App\Http\Controllers\Mobile;


use App\Logics\SiteLogic;
use Illuminate\Support\Facades\Config;

class SiteController extends BaseController
{
    // 一般操作
    public function initialize()
    {
        parent::initialize();
    }

    // 当前服务器域名
    public function cdn()
    {
        $domain = Config::get('site.cdnHost');
        $domain = substr($domain, -1) == '/' ? substr($domain, 0, -1) : $domain;

        return $this->success(['domain' => $domain]);
    }

    // 广告
    public function adv()
    {
        $lists = (new SiteLogic())->adv();

        return $this->success($lists);
    }

    // 用户协议
    public function service()
    {
        return $this->info(1);
    }

    // 隐私协议
    public function privacy()
    {
        return $this->info(2);
    }

    // 联系我们
    public function contact()
    {
        return $this->info(3);
    }

    // 帮助中心
    public function help()
    {
        return $this->info(4);
    }

    // 关于我们
    public function about()
    {
        return $this->info(5);
    }

    // 获取所有的栏目
    public function cates()
    {
        $lists = (new SiteLogic())->cates();

        return $this->success($lists);
    }

    // 获取所有的标签
    public function tags()
    {
        $lists = (new SiteLogic())->tags();

        return $this->success($lists);
    }

    // 翻译
    public function translate()
    {
        $result = (new SiteLogic())->translate();

        return $this->success($result);
    }

    #############################################################################################
    // 获取系统设置的文章
    protected function info($id)
    {
        $info = (new SiteLogic())->info($id);

        return $this->success($info);
    }
}


